import {createRouter, createWebHashHistory, RouteRecordRaw} from "vue-router";
declare module 'vue-router' {
    interface RouteMeta {
        title:string
    }
}
const Layout = () => import('@/layout/index.vue')
const routes:RouteRecordRaw[] = [
    {
        path: '/login',
        component: () => import('@/views/login/index.vue'),
        meta: {
            title: '登录页'
        }
    },
    {
        path: '/',
        redirect: '/index',
        component: Layout,
        children: [
            {
                path: '/index',
                component: () => import('@/views/dashboard/index.vue'),
                meta: {
                    title: '首页'
                }
            },
        ]
    },
    {
        path: '/:pathMatch(.*)*',
        component: () => import('@/views/404.vue'),
        meta: {
            title: '找不到页面'
        }
    },
]

export const router = createRouter({
    history: createWebHashHistory(),
    routes,
    scrollBehavior(to, from, savedPosition) {
        return savedPosition ? savedPosition : {top: 0}
    }
})